package day01;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Servlet的生命周期
 */
public class A04_ServletLifecycle extends HttpServlet {


    /**
     * 1.出生 --或者 --死亡
     *  Servlet对象什么时候创建的?(出生)
     *      请求第一次到达Servlet的时候,对象会被创建,并且初始化
     *
     */
//    执行时期 ,在Servlet对象创建的时候执行,
    @Override
    public void init(ServletConfig config) throws ServletException {
        System.out.println("初始化Servlet对象");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("测试Servlet的生命周期");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
